<?php
	include('include/configs.inc.php');
	
	if(!empty($_GET['id'])) {
		$sqlbiens = "SELECT * FROM bien INNER JOIN type_bien ON type_bien.id=bien.id_type_bien INNER JOIN photo ON photo.id=bien.id_photo WHERE bien.id=".$_GET['id'];
		$sqldispos = "SELECT DATE_FORMAT(debut_dispo, '%d/%m/%Y') AS debut_dispo, DATE_FORMAT(fin_dispo, '%d/%m/%Y') AS fin_dispo FROM dispo_bien WHERE id_bien=".$_GET['id'];
		$sqllocations = "SELECT nom, prenom, DATE_FORMAT(debut_location, '%d/%m/%Y') AS debut_location, DATE_FORMAT(fin_location, '%d/%m/%Y') AS fin_location FROM location_bien JOIN user ON location_bien.id_locataire=user.id WHERE id_bien=".$_GET['id'];
		$sqlavis = "SELECT avis, note, nom, prenom FROM avis_bien JOIN user ON user.id=avis_bien.id_locataire WHERE id_bien=".$_GET['id'];
		$sql1 = "SELECT id FROM avis_bien WHERE id_locataire=".$_SESSION['UID']." AND id_bien=".$_GET['id'];
		$sql2 = "SELECT id FROM archive_location_bien WHERE id_locataire=".$_SESSION['UID']." AND id_bien=".$_GET['id'];
		
		$biens = $connect->query($sqlbiens);
		$dispos = $connect->query($sqldispos);
		$locations = $connect->query($sqllocations);
		$avis = $connect->query($sqlavis);
		$query1 = $connect->query($sql1)->num_rows;
		$query2 = $connect->query($sql2)->num_rows;
	}
	
	include('template/ficheBien.html');
?>